package com.lavender.aop.spring.aop;

import com.lavender.aop.spring.aop.service.DoSthService;
import com.lavender.aop.spring.aop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class TestCommand implements CommandLineRunner {

    @Autowired
    private UserService userService;

    @Autowired
    private DoSthService doSthService;

    @Override
    public void run(String... args) throws Exception {
        /**
         * Spring Boot 2.x默认使用Cglib来做动态代理。
         * 默认：class com.lavender.aop.spring.aop.service.impl.UserServiceImpl$$EnhancerBySpringCGLIB$$159be275
         *
         * yml配置：
         * spring:
         *   aop:
         *     proxy-target-class: false
         * 会使用JDK动态代理：class com.sun.proxy.$Proxy55
         */
        System.out.println(userService.getClass().getName());
        /**
         * Spring Boot 2.x默认使用Cglib来做动态代理。
         * 默认：class com.lavender.aop.spring.aop.service.impl.DoSthServiceImpl$$EnhancerBySpringCGLIB$$c6bd31e0
         *
         * yml配置：
         * spring:
         *   aop:
         *     proxy-target-class: false
         * 会使用JDK动态代理：class com.sun.proxy.$Proxy56
         */
        System.out.println(doSthService.getClass().getName());
//        userService.testIntroduction();
//        doSthService.doSth();
    }

}
